<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>菜单栏</title>
    <script src="scripts/jquery-3.4.1.min.js"></script>
    <script src="scripts/vue.js"></script>
    <style>
        *{
         margin: 0;
         padding: 0;
         box-sizing: border-box;   
        }
        .page{
            width: 100vw;
            height: 100vh;
            background-color: #efefef;
            position: fixed;
            left: 0;
            top: 0;
        }
        .rightMenu{
            width: 50vw;
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            transform: translateX(100vw);
            background: skyblue;
            transition: transform 0.5s;
        }
        /* .active{
            transform: translateX(50vw);
        } */
    </style>
</head>
<body>
    <div id=app>
        <div class="page">
            首页
            <button type="button"  @click="ToggleMenu">切换侧边栏</button>
        </div>

        <div class="rightMenu" :style="{transform: 'translateX('+menuWidth+'vw)'}">
            侧边栏
            
        </div>
    </div>

    <script>
        let app=new Vue({
            el:"#app",
            data:{
                menuWidth:50
            },
            methods:{
                ToggleMenu:function(){
                    if(this.menuWidth==50){
                        this.menuWidth=100;
                    }else{
                        this.menuWidth=50;
                    }                    
                }
            }
        })
    </script>
</body>
</html>